/***********************************************************************************************************************
* Copyright (C) . All rights reserved.
***********************************************************************************************************************/

/***********************************************************************************************************************
* File Name    : main.c
* Version      :  
* Device(s)    : BAT32G157
* Tool-Chain   : MDK(armcc)
* Description  : This file is a template.
* Creation Date: 2019/12/25
***********************************************************************************************************************/

/***********************************************************************************************************************
Macro Definitions
***********************************************************************************************************************/

/***********************************************************************************************************************
Includes
***********************************************************************************************************************/
#include <stdio.h>
#include "BAT32G157.h"
#include "userdefine.h"
#include "sci.h"

int main()
{
	MD_STATUS status;
	uint32_t i;
	
//-----------------------------------------------------------------------
// Init UART0 for retarget printf/scanf etc. 
//----------------------------------------------------------------------- 
	SystemCoreClockUpdate();
	status = UART0_Init(SystemCoreClock, 19200);
	if(status == MD_ERROR)
	{
		while(1); // The baud rate cannot get at the current system clock frequency.
	}
	
//-----------------------------------------------------------------------
// Flash CRC test
//-----------------------------------------------------------------------
	printf("\n");
	printf("PGCRCL = 0x%04X\n", SAF->PGCRCL);
	SAF->CRC0CTL = 0x80;
	__SEV();
	__WFE();
	__WFE();
	printf("PGCRCL = 0x%04X\n", SAF->PGCRCL);	
	
	while(1);
}
